package biz.obake.team.touchprotector.lfd;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.c;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.g.c;
import biz.obake.team.touchprotector.lfd.c;
import biz.obake.team.touchprotector.tpservice.TPService;

public class LfdPackageActivity extends c implements c.b {
    private GridView t;
    private g u;
    /* access modifiers changed from: private */
    public c v;

    class a implements AdapterView.OnItemClickListener {
        a() {
        }

        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            LfdPackageActivity.this.J(i);
        }
    }

    class b implements View.OnClickListener {
        b() {
        }

        public void onClick(View view) {
            LfdPackageActivity.this.startActivity(new Intent("android.intent.action.VIEW", new Uri.Builder().scheme("market").authority("details").appendQueryParameter("id", LfdPackageActivity.this.v.j()).build()));
        }
    }

    private void I(Intent intent) {
        try {
            this.v = new c(intent.getStringExtra("packageName"));
            ((ImageView) findViewById(R.id.icon)).setImageDrawable(this.v.h());
            ((TextView) findViewById(R.id.title)).setText(this.v.n());
            ((TextView) findViewById(R.id.summary)).setText(this.v.m());
            ((TextView) findViewById(R.id.provider)).setText(this.v.k());
            this.t = (GridView) findViewById(R.id.gridView);
            g gVar = new g(this.v);
            this.u = gVar;
            this.t.setAdapter(gVar);
            this.t.setOnItemClickListener(new a());
            findViewById(R.id.card).setOnClickListener(new b());
        } catch (PackageManager.NameNotFoundException | c.b unused) {
            finish();
        }
    }

    /* access modifiers changed from: private */
    public void J(int i) {
        f.d().i(this.v.a(i));
        this.u.notifyDataSetChanged();
        TPService.k("Design", "LfdPackage");
    }

    private void K() {
        int i;
        GridView gridView;
        if ("Locked".equals(biz.obake.team.touchprotector.g.c.c("TPService.State"))) {
            gridView = this.t;
            i = 4;
        } else {
            gridView = this.t;
            i = 0;
        }
        gridView.setVisibility(i);
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.lfd_package_activity);
        I(getIntent());
    }

    /* access modifiers changed from: protected */
    public void onNewIntent(Intent intent) {
        I(intent);
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        super.onPause();
        biz.obake.team.touchprotector.g.c.h(this);
    }

    public void onRamPrefsChanged(String str) {
        if (((str.hashCode() == -2066548004 && str.equals("TPService.State")) ? (char) 0 : 65535) == 0) {
            K();
        }
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        K();
        biz.obake.team.touchprotector.g.c.e(this);
    }
}
